<?php

namespace app\admin\model;

use think\Model;


class Feedback extends Model
{

    

    

    // 表名
    protected $name = 'feedback';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'postion_text'
    ];
    

    
    public function getPostionList()
    {
        return ['1' => __('Postion 1'), '2' => __('Postion 2'), '3' => __('Postion 3')];
    }


    public function getPostionTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['postion']) ? $data['postion'] : '');
        $list = $this->getPostionList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('User', 'uid', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
